package cc.cinemate.api;

public class CinemateUrlFactory {
	
	public CinemateUrlFactory(String passkey){
		PASSKEY = passkey;
		RESPONSE_FORMAT = CinemateResponseFormat.xml;
	}
	public CinemateUrlFactory(String passkey, CinemateResponseFormat responseFormat){
		PASSKEY = passkey;
		RESPONSE_FORMAT = responseFormat;
	}
	
	private String PASSKEY;
	private CinemateResponseFormat RESPONSE_FORMAT;
	private String BASE_URL = "http://cinemate.cc/";
	private String MOVIE_NEW = "export/movie/new/?format={FORMAT}";
	private String MOVIE_SEARCH = "export/movie/search/?term={TERM}&format={FORMAT}";
	private String PERSON_SEARCH = "export/person/search/?term={TERM}&format={FORMAT}";
	private String ACCOUNT_PROFILE = "export/account/profile/{PASSKEY}/?format={FORMAT}";
	private String ACCOUNT_UPDATELIST = "export/account/updatelist/{PASSKEY}/?format={FORMAT}";
	private String ACCOUNT_WATCHLIST = "export/account/watchlist/{PASSKEY}/?format={FORMAT}";
	private String STATUS_NEW = "export/stats/new/?format={xml}";
	
	private String ConcatUrl(String url){
		return ConcatUrl(url, "");
	}
	private String ConcatUrl(String url, String term){
		return String.format("%s%s", BASE_URL, url)
			.replace("{TERM}", term)
			.replace("{PASSKEY}", PASSKEY)
			.replace("{FORMAT}", RESPONSE_FORMAT.toString());
	}
	
	public String MovieNew(){
		return ConcatUrl(MOVIE_NEW);
	}
	public String MovieSearch(String term){
		return ConcatUrl(MOVIE_SEARCH, term);
	}
	public String Person_Search(String term){
		return ConcatUrl(PERSON_SEARCH, term);
	}
	public String AccountProfile(){
		return ConcatUrl(ACCOUNT_PROFILE);
	}
	public String AccountUpdateList(){
		return ConcatUrl(ACCOUNT_UPDATELIST);
	}
	public String AccountWatchList(){
		return ConcatUrl(ACCOUNT_WATCHLIST);
	}
	public String StatusNew(){
		return ConcatUrl(STATUS_NEW);
	}
}
